home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Interfaces / Universal Interfaces 2.0a3 / Universal AIncludes / OSUtils.a < prev    next >
Encoding:
Text File  |  1994-11-11  |  10.1 KB  |  570 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        OSUtils.a
  3. ;
  4. ;    Copyright:    © 1984-1994 by Apple Computer, Inc.
  5. ;                All rights reserved.
  6. ;
  7. ;    Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8. ;
  9. ;    Bugs?:        If you find a problem with this file, send the file and version
  10. ;                information (from above) and the problem description to:
  11. ;
  12. ;                    Internet:    apple.bugs@applelink.apple.com
  13. ;                    AppleLink:    APPLE.BUGS
  14. ;
  15. ;
  16.  
  17.     IF &TYPE('__OSUTILS__') = 'UNDEFINED' THEN
  18. __OSUTILS__ SET 1
  19.  
  20.  
  21.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  22.     include 'Types.a'
  23.     ENDIF
  24. ;        include 'ConditionalMacros.a'                                ;
  25.  
  26.     IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
  27.     include 'MixedMode.a'
  28.     ENDIF
  29.  
  30.     IF &TYPE('__MEMORY__') = 'UNDEFINED' THEN
  31.     include 'Memory.a'
  32.     ENDIF
  33.  
  34. useFree                            EQU        0
  35. useATalk                        EQU        1
  36. useAsync                        EQU        2
  37. useExtClk                        EQU        3                    ;Externally clocked
  38. useMIDI                            EQU        4
  39. ; Environs Equates 
  40. curSysEnvVers                    EQU        2                    ;Updated to equal latest SysEnvirons version
  41. ; Machine Types 
  42. envMac                            EQU        -1
  43. envXL                            EQU        -2
  44. envMachUnknown                    EQU        0
  45. env512KE                        EQU        1
  46. envMacPlus                        EQU        2
  47. envSE                            EQU        3
  48. envMacII                        EQU        4
  49. envMacIIx                        EQU        5
  50. envMacIIcx                        EQU        6
  51. envSE30                            EQU        7
  52. envPortable                        EQU        8
  53. envMacIIci                        EQU        9
  54. envMacIIfx                        EQU        11
  55. ; CPU types 
  56. envCPUUnknown                    EQU        0
  57.  
  58. env68000                        EQU        1
  59. env68010                        EQU        2
  60. env68020                        EQU        3
  61. env68030                        EQU        4
  62. env68040                        EQU        5
  63. ; Keyboard types 
  64. envUnknownKbd                    EQU        0
  65. envMacKbd                        EQU        1
  66. envMacAndPad                    EQU        2
  67. envMacPlusKbd                    EQU        3
  68. envAExtendKbd                    EQU        4
  69. envStandADBKbd                    EQU        5
  70. envPrtblADBKbd                    EQU        6
  71. envPrtblISOKbd                    EQU        7
  72. envStdISOADBKbd                    EQU        8
  73. envExtISOADBKbd                    EQU        9
  74. false32b                        EQU        0                    ;24 bit addressing error
  75. true32b                            EQU        1                    ;32 bit addressing error
  76. ; result types for RelString Call 
  77. sortsBefore                        EQU        -1                    ;first string < second string
  78. sortsEqual                        EQU        0                    ;first string = second string
  79. sortsAfter                        EQU        1                    ;first string > second string
  80.  
  81. ; Toggle results 
  82. toggleUndefined                    EQU        0
  83. toggleOK                        EQU        1
  84. toggleBadField                    EQU        2
  85. toggleBadDelta                    EQU        3
  86. toggleBadChar                    EQU        4
  87. toggleUnknown                    EQU        5
  88. toggleBadNum                    EQU        6
  89. toggleOutOfRange                EQU        7                    ;synonym for toggleErr3
  90. toggleErr3                        EQU        7
  91. toggleErr4                        EQU        8
  92. toggleErr5                        EQU        9
  93. ; Date equates 
  94. smallDateBit                    EQU        31                    ;Restrict valid date/time to range of Time global
  95. togChar12HourBit                EQU        30                    ;If toggling hour by char, accept hours 1..12 only
  96. togCharZCycleBit                EQU        29                    ;Modifier for togChar12HourBit: accept hours 0..11 only
  97. togDelta12HourBit                EQU        28                    ;If toggling hour up/down, restrict to 12-hour range (am/pm)
  98. genCdevRangeBit                    EQU        27                    ;Restrict date/time to range used by genl CDEV
  99. validDateFields                    EQU        -1
  100. maxDateField                    EQU        10
  101. eraMask                            EQU        $0001
  102. yearMask                        EQU        $0002
  103. monthMask                        EQU        $0004
  104. dayMask                            EQU        $0008
  105. hourMask                        EQU        $0010
  106. minuteMask                        EQU        $0020
  107. secondMask                        EQU        $0040
  108. dayOfWeekMask                    EQU        $0080
  109. dayOfYearMask                    EQU        $0100
  110. weekOfYearMask                    EQU        $0200
  111. pmMask                            EQU        $0400
  112. dateStdMask                        EQU        $007F                ;default for ValidDate flags and ToggleDate TogglePB.togFlags
  113.  
  114. eraField                        EQU        0
  115. yearField                        EQU        1
  116. monthField                        EQU        2
  117. dayField                        EQU        3
  118. hourField                        EQU        4
  119. minuteField                        EQU        5
  120. secondField                        EQU        6
  121. dayOfWeekField                    EQU        7
  122. dayOfYearField                    EQU        8
  123. weekOfYearField                    EQU        9
  124. pmField                            EQU        10
  125. res1Field                        EQU        11
  126. res2Field                        EQU        12
  127. res3Field                        EQU        13
  128.  
  129. dummyType                        EQU        0
  130. vType                            EQU        1
  131. ioQType                            EQU        2
  132. drvQType                        EQU        3
  133. evType                            EQU        4
  134. fsQType                            EQU        5
  135. sIQType                            EQU        6
  136. dtQType                            EQU        7
  137. nmType                            EQU        8
  138.  
  139. OSTrap                            EQU        0
  140. ToolTrap                        EQU        1
  141.  
  142. SysParmType             RECORD    0
  143. valid                     ds.b    1
  144. aTalkA                     ds.b    1
  145. aTalkB                     ds.b    1
  146. config                     ds.b    1
  147. portA                     ds.w    1
  148. portB                     ds.w    1
  149. alarm                     ds.l    1
  150. font                     ds.w    1
  151. kbdPrint                 ds.w    1
  152. volClik                     ds.w    1
  153. misc                     ds.w    1
  154. sizeof                     EQU    20
  155.                         ENDR
  156.  
  157. QElem                     RECORD    0
  158. qLink                     ds.l    1
  159. qType                     ds.w    1
  160. qData                     ds.w    1
  161. sizeof                     EQU    8
  162.                         ENDR
  163.  
  164. QHdr                     RECORD    0
  165. qFlags                     ds.w    1
  166. qHead                     ds.l    1
  167. qTail                     ds.l    1
  168. sizeof                     EQU    10
  169.                         ENDR
  170.  
  171. DeferredTask             RECORD    0
  172. qLink                     ds.l    1
  173. qType                     ds.w    1
  174. dtFlags                     ds.w    1
  175. dtAddr                     ds.l    1
  176. dtParam                     ds.l    1
  177. dtReserved                 ds.l    1
  178. sizeof                     EQU    20
  179.                         ENDR
  180.  
  181. SysEnvRec                 RECORD    0
  182. environsVersion             ds.w    1
  183. machineType                 ds.w    1
  184. systemVersion             ds.w    1
  185. processor                 ds.w    1
  186. hasFPU                     ds.b    1
  187. hasColorQD                 ds.b    1
  188. keyBoardType             ds.w    1
  189. atDrvrVersNum             ds.w    1
  190. sysVRefNum                 ds.w    1
  191. sizeof                     EQU    16
  192.                         ENDR
  193.  
  194. MachineLocation         RECORD    0
  195. latitude                 ds.l    1
  196. longitude                 ds.l    1
  197. VariantLevel0Begin        EQU    *
  198. dlsDelta                 ds.b    1                                    ;signed byte; daylight savings delta
  199.                         ORG        VariantLevel0Begin
  200. gmtDelta                 ds.l    1                                    ;must mask - see documentation
  201. sizeof                     EQU    12
  202.                         ENDR
  203.  
  204. DateTimeRec             RECORD    0
  205. year                     ds.w    1
  206. month                     ds.w    1
  207. day                         ds.w    1
  208. hour                     ds.w    1
  209. minute                     ds.w    1
  210. second                     ds.w    1
  211. dayOfWeek                 ds.w    1
  212. sizeof                     EQU    14
  213.                         ENDR
  214.  
  215. LongDateCvt             RECORD    0
  216. VariantLevel0Begin        EQU    *
  217. c                         ds        wide
  218.                         ORG        VariantLevel0Begin
  219. lHigh                     ds.l    1
  220. lLow                     ds.l    1
  221.  
  222. sizeof                     EQU    8
  223.                         ENDR
  224.  
  225. LongDateRec             RECORD    0
  226. VariantLevel0Begin        EQU    *
  227. era                         ds.w    1
  228. year                     ds.w    1
  229. month                     ds.w    1
  230. day                         ds.w    1
  231. hour                     ds.w    1
  232. minute                     ds.w    1
  233. second                     ds.w    1
  234. dayOfWeek                 ds.w    1
  235. dayOfYear                 ds.w    1
  236. weekOfYear                 ds.w    1
  237. pm                         ds.w    1
  238. res1                     ds.w    1
  239. res2                     ds.w    1
  240. res3                     ds.w    1
  241.  
  242.                         ORG        VariantLevel0Begin
  243. list                     ds.w    14                                ;Index by LongDateField!
  244.                         ORG        VariantLevel0Begin
  245. eraAlt                     ds.w    1
  246. oldDate                     ds        DateTimeRec
  247.  
  248. sizeof                     EQU    28
  249.                         ENDR
  250.  
  251. TogglePB                 RECORD    0
  252. togFlags                 ds.l    1                                    ;caller normally sets low word to dateStdMask=$7F
  253. amChars                     ds.l    1                                    ;from 'itl0', but uppercased
  254. pmChars                     ds.l    1                                    ;from 'itl0', but uppercased
  255. reserved                 ds.l    4
  256. sizeof                     EQU    28
  257.                         ENDR
  258.  
  259.     IF GENERATING68K THEN
  260.         Macro
  261.         _LongDateToSeconds
  262.             dc.w     $2F3C
  263.             dc.w     $8008
  264.             dc.w     $FFF2
  265.             dc.w     $A8B5
  266.         EndM
  267.     ELSE
  268.         IMPORT    LongDateToSeconds
  269.     ENDIF
  270.  
  271.     IF GENERATING68K THEN
  272.         Macro
  273.         _LongSecondsToDate
  274.             dc.w     $2F3C
  275.             dc.w     $8008
  276.             dc.w     $FFF0
  277.             dc.w     $A8B5
  278.         EndM
  279.     ELSE
  280.         IMPORT    LongSecondsToDate
  281.     ENDIF
  282.  
  283.     IF GENERATING68K THEN
  284.         Macro
  285.         _ToggleDate
  286.             dc.w     $2F3C
  287.             dc.w     $820E
  288.             dc.w     $FFEE
  289.             dc.w     $A8B5
  290.         EndM
  291.     ELSE
  292.         IMPORT    ToggleDate
  293.     ENDIF
  294.  
  295.     IF GENERATING68K THEN
  296.         Macro
  297.         _ValidDate
  298.             dc.w     $2F3C
  299.             dc.w     $820C
  300.             dc.w     $FFE4
  301.             dc.w     $A8B5
  302.         EndM
  303.     ELSE
  304.         IMPORT    ValidDate
  305.     ENDIF
  306.  
  307.     IF GENERATING68K THEN
  308.         Macro
  309.         _IsMetric
  310.             move.w    #$0004,-(sp)
  311.             dc.w     $A9ED
  312.         EndM
  313.     ELSE
  314.         IMPORT    IsMetric
  315.     ENDIF
  316.  
  317.     IF GENERATING68K THEN
  318.         Macro
  319.         _GetSysPPtr
  320.             dc.w     $2EBC
  321.             dc.w     $0000
  322.             dc.w     $01F8
  323.         EndM
  324.     ELSE
  325.         IMPORT    GetSysPPtr
  326.     ENDIF
  327.  
  328.     IF GENERATING68K THEN
  329.         _ReadDateTime:    OPWORD    $A039
  330.     ELSE
  331.         IMPORT    ReadDateTime
  332.     ENDIF
  333.  
  334.     IF GENERATING68K THEN
  335.         Macro
  336.         _GetDateTime
  337.             dc.w     $20B8
  338.             dc.w     $020C
  339.         EndM
  340.     ELSE
  341.         IMPORT    GetDateTime
  342.     ENDIF
  343.  
  344.     IF GENERATING68K THEN
  345.         _SetDateTime:    OPWORD    $A03A
  346.     ELSE
  347.         IMPORT    SetDateTime
  348.     ENDIF
  349.  
  350.     IF GENERATING68K THEN
  351.         Macro
  352.         _SetTime
  353.             dc.w     $A9C7
  354.             dc.w     $A03A
  355.         EndM
  356.     ELSE
  357.         IMPORT    SetTime
  358.     ENDIF
  359.  
  360.     IF GENERATING68K THEN
  361.         Macro
  362.         _GetTime
  363.             dc.w     $2038
  364.             dc.w     $020C
  365.             dc.w     $A9C6
  366.         EndM
  367.     ELSE
  368.         IMPORT    GetTime
  369.     ENDIF
  370.  
  371.     IF GENERATING68K THEN
  372.         _SecondsToDate:    OPWORD    $A9C6
  373.     ELSE
  374.         IMPORT    SecondsToDate
  375.     ENDIF
  376.  
  377.     IF GENERATING68K THEN
  378.         _SysBeep:    OPWORD    $A9C8
  379.     ELSE
  380.         IMPORT    SysBeep
  381.     ENDIF
  382.  
  383.     IF GENERATING68K THEN
  384.         _DTInstall:    OPWORD    $A082
  385.     ELSE
  386.         IMPORT    DTInstall
  387.     ENDIF
  388.  
  389.     IF GENERATING68K THEN
  390.         Macro
  391.         GetMMUMode
  392.             move.B $0CB2,(sp)
  393.         EndM
  394.     ELSE
  395.         IMPORT    GetMMUMode
  396.     ENDIF
  397.  
  398.     IF GENERATING68K  THEN
  399.     IF GENERATING68K THEN
  400.         Macro
  401.         _SwapMMUMode
  402.             dc.w     $1010
  403.             dc.w     $A05D
  404.             dc.w     $1080
  405.         EndM
  406.     ELSE
  407.         IMPORT    SwapMMUMode
  408.     ENDIF
  409.  
  410.     ENDIF
  411.     IF SystemSixOrLater  THEN
  412.     IF GENERATING68K THEN
  413.         _SysEnvirons:    OPWORD    $A090
  414.     ELSE
  415.         IMPORT    SysEnvirons
  416.     ENDIF
  417.  
  418.     ELSE
  419.     ENDIF
  420.     IF GENERATING68K THEN
  421.         Macro
  422.         _Delay
  423.             dc.w     $A03B
  424.             dc.w     $2280
  425.         EndM
  426.     ELSE
  427.         IMPORT    Delay
  428.     ENDIF
  429.  
  430. ;
  431. ;    GetTrapAddress and SetTrapAddress are obsolete and should not
  432. ;    be used. Always use NGetTrapAddress and NSetTrapAddress instead.
  433. ;    The old routines will not be supported for PowerPC apps.
  434. ;
  435.     IF OLDROUTINENAMES  ** ¬ GENERATINGCFM  THEN
  436.     IF GENERATING68K THEN
  437.         _GetTrapAddress:    OPWORD    $A146
  438.     ELSE
  439.         IMPORT    GetTrapAddress
  440.     ENDIF
  441.  
  442.     IF GENERATING68K THEN
  443.         _SetTrapAddress:    OPWORD    $A047
  444.     ELSE
  445.         IMPORT    SetTrapAddress
  446.     ENDIF
  447.  
  448.     ENDIF
  449.     IF GENERATING68K THEN
  450.         _GetOSTrapAddress:    OPWORD    $A346
  451.     ELSE
  452.         IMPORT    GetOSTrapAddress
  453.     ENDIF
  454.  
  455.     IF GENERATING68K THEN
  456.         _SetOSTrapAddress:    OPWORD    $A247
  457.     ELSE
  458.         IMPORT    SetOSTrapAddress
  459.     ENDIF
  460.  
  461.     IF GENERATING68K THEN
  462.         _GetToolTrapAddress:    OPWORD    $A746
  463.     ELSE
  464.         IMPORT    GetToolTrapAddress
  465.     ENDIF
  466.  
  467.     IF GENERATING68K THEN
  468.         _SetToolTrapAddress:    OPWORD    $A647
  469.     ELSE
  470.         IMPORT    SetToolTrapAddress
  471.     ENDIF
  472.  
  473.     IF GENERATING68K THEN
  474.         _GetToolboxTrapAddress:    OPWORD    $A746
  475.     ELSE
  476.         IMPORT    GetToolboxTrapAddress
  477.     ENDIF
  478.  
  479.     IF GENERATING68K THEN
  480.         _SetToolboxTrapAddress:    OPWORD    $A647
  481.     ELSE
  482.         IMPORT    SetToolboxTrapAddress
  483.     ENDIF
  484.  
  485.     IF GENERATING68K THEN
  486.         _Enqueue:    OPWORD    $A96F
  487.     ELSE
  488.         IMPORT    Enqueue
  489.     ENDIF
  490.  
  491.     IF GENERATING68K THEN
  492.         _Dequeue:    OPWORD    $A96E
  493.     ELSE
  494.         IMPORT    Dequeue
  495.     ENDIF
  496.  
  497.     IF ¬ SystemSevenOrLater  THEN
  498.     ENDIF
  499.     IF GENERATING68K THEN
  500.         _InitUtil:    OPWORD    $A03F
  501.     ELSE
  502.         IMPORT    InitUtil
  503.     ENDIF
  504.  
  505.     IF GENERATING68K  THEN
  506.     IF GENERATING68K THEN
  507.         Macro
  508.         _FlushInstructionCache
  509.             moveq    #1,d0
  510.             dc.w     $A098
  511.         EndM
  512.     ELSE
  513.         IMPORT    FlushInstructionCache
  514.     ENDIF
  515.  
  516.     IF GENERATING68K THEN
  517.         Macro
  518.         _FlushDataCache
  519.             moveq    #3,d0
  520.             dc.w     $A098
  521.         EndM
  522.     ELSE
  523.         IMPORT    FlushDataCache
  524.     ENDIF
  525.  
  526.     IF GENERATING68K THEN
  527.         _FlushCodeCache:    OPWORD    $A0BD
  528.     ELSE
  529.         IMPORT    FlushCodeCache
  530.     ENDIF
  531.  
  532.     IF GENERATING68K THEN
  533.         Macro
  534.         _FlushCodeCacheRange
  535.             moveq    #9,d0
  536.             dc.w     $A098
  537.         EndM
  538.     ELSE
  539.         IMPORT    FlushCodeCacheRange
  540.     ENDIF
  541.  
  542.     ENDIF
  543.     IF GENERATING68K THEN
  544.         Macro
  545.         _ReadLocation
  546.             dc.w     $203C
  547.             dc.w     $000C
  548.             dc.w     $00E4
  549.             dc.w     $A051
  550.         EndM
  551.     ELSE
  552.         IMPORT    ReadLocation
  553.     ENDIF
  554.  
  555.     IF GENERATING68K THEN
  556.         Macro
  557.         _WriteLocation
  558.             dc.w     $203C
  559.             dc.w     $000C
  560.             dc.w     $00E4
  561.             dc.w     $A052
  562.         EndM
  563.     ELSE
  564.         IMPORT    WriteLocation
  565.     ENDIF
  566.  
  567.     IF OLDROUTINENAMES  THEN
  568.     ENDIF
  569.     ENDIF ; __OSUTILS__
  570.